<script setup lang="ts">
import SysAreaApi from "/@/api/common/SysAreaApi.ts";
const attrs = useAttrs()
const props = defineProps({
  modelValue:{

  },
  checkStrictly: {

  }
})
const emits= defineEmits(['update:modelValue'])
const selected = ref(null)

const handInputChange=()=> {
  emits('update:modelValue',selected.value)
}

watch(()=>props.modelValue,()=> {
  selected.value = props.modelValue
},{immediate: true})
const treeData = ref(null)
onMounted(async () => {
  let {data} = await SysAreaApi.getSysAreaList()
  treeData.value = data
})

</script>

<template>
  <ElCascader v-model="selected" ref="treeRef"  v-bind="attrs"
              clearable
              style="width: 100%;"
              :options="treeData" :props="{
        label: 'name',
        value: 'code',
        children: 'children',
        emitPath: false,
        checkStrictly: checkStrictly != undefined && checkStrictly != false,
        multiple: false
      }" :onChange="handInputChange" >
  </ElCascader>
</template>

<style scoped lang="scss">

</style>
